#ifndef _DISP_MANAGER_H
#define _DISP_MANAGER_H

#include <pic_operation.h>
/*一块区域，用于显示图标或文字*/
typedef struct Layout {
	int iTopLeftX;     /*左上角坐标*/   
	int iTopLeftY;
	int iBotRightX;     /*右下角坐标*/
	int iBotRightY;
	char *strIconName;  /*图标路径*/
}T_Layout, *PT_Layout;

/*页面布局区域信息*/
typedef struct PageLayout {
	int iTopLeftX;       /*左上角坐标*/    
	int iTopLeftY;
	int iBotRightX;	    /*右下角坐标*/
	int iBotRightY;
	int iBpp;            /*单个像素点长度*/  
	int iMaxTotalBytes;    /*最大字节数*/
	PT_Layout atLayout;    
}T_PageLayout, *PT_PageLayout;

/*缓冲区状态*/
typedef enum {
	VMS_FREE = 0,          /*空闲*/
	VMS_USED_FOR_PREPARE,  /**/
	VMS_USED_FOR_CUR,	
}E_VideoMemState;

/*缓冲区内容状态*/
typedef enum {
	PS_BLANK = 0,
	PS_GENERATING,
	PS_GENERATED,	
}E_PicState;

/*缓冲区结构体*/
typedef struct VideoMem {
	int iID;                        /*缓冲区ID与页面ID对应*/                                   
	int bDevFrameBuffer;            /* 1: 这个VideoMem是显示设备的显存; 0: 只是一个普通缓存 */   
	E_VideoMemState eVideoMemState; /*缓冲区状态*/
	E_PicState ePicState;           /*缓冲区内容状态*/  
	T_PixelDatas tPixelDatas;       /*缓冲区图像数据*/ 
	struct VideoMem *ptNext;        
}T_VideoMem, *PT_VideoMem;

/*显示设备结构体*/
typedef struct DispOpr {
	char *name;            /*设备名*/         
	int iXres;    	       /*分辨率*/           
	int iYres;               
	int iBpp;    		  /*单个像素点长度*/            
	int iLineWidth;        /*一行所占字节数*/  
	uint8_t *pucDispMem;   /*显存首地址*/
	int (*DeviceInit)(void);     /*设备初始化函数*/   
	int (*ShowPixel)(int iPenX, int iPenY, uint32_t dwColor);    /*秒点函数*/
	int (*CleanScreen)(uint32_t dwBackColor);  				/*清屏函数*/                  
	int (*ShowPage)(PT_VideoMem ptVideoMem);                    /* 缓冲区写入显存 */     
	struct DispOpr *ptNext;      
}T_DispOpr, *PT_DispOpr;

/*显示设备注册函数*/
int RegisterDispOpr(PT_DispOpr ptDispOpr);
/*显示设备*/
void ShowDispOpr(void);
/*显示设备初始化*/
int DisplayInit(void);
/*指定默认设备并初始化*/
void SelectAndInitDefaultDispDev(char *name);
/*得到默认设备*/
PT_DispOpr GetDefaultDispDev(void);
/*得到当场默认设备分辨率*/
int GetDispResolution(int *piXres, int *piYres, int *piBpp);
/*分配缓冲区*/
int AllocVideoMem(int iNum);
/*得到当前显示设备显存地址*/
PT_VideoMem GetDevVideoMem(void);
/*取得一块显示缓冲区*/
PT_VideoMem GetVideoMem(int iID, int bCur);
/*释放缓冲区*/
void PutVideoMem(PT_VideoMem ptVideoMem);
/*清除缓冲区为某颜色*/
void ClearVideoMem(PT_VideoMem ptVideoMem, uint32_t dwColor);
/*清除缓冲区中某区域为某颜色*/
void ClearVideoMemRegion(PT_VideoMem ptVideoMem, PT_PageLayout ptPageLayout, uint32_t dwColor);
/*FB设备初始化*/
int FBInit(void);

#endif 

